package com.bw.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class Myaop {

    /**
     * 前置通知  原方法执行之前调用
     * @param joinPoint
     */
    @Before("execution(* com.bw.service.*.*(..))")
    public void  before(JoinPoint joinPoint){
        System.out.println("方法名" +joinPoint.getSignature().getName());
        System.out.println("参数" +joinPoint.getArgs());
    }

    /**
     * 环绕通知
     * @param joinPoint
     * @return
     * @throws Throwable
     */
   // @Around("execution(* com.bw.service.*.*(..))")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {

        System.out.println("方法名" +joinPoint.getSignature().getName());
        System.out.println("参数" +joinPoint.getArgs());

        Object proceed = joinPoint.proceed();

        return  proceed;

    }
}
